package useful_tools;

import java.util.concurrent.CountDownLatch;

enum Enum {
    ONE(1, "one"), Two(2, "two"), Three(3, "three");

    Enum(int id, String mes) {
        this.id = id;
        this.mes = mes;
    }
    private final int id;
    private final String mes;

    public int getId() {
        return id;
    }

    public String getMes() {
        return mes;
    }
}

public class CountDownLatchDemo {
    public static void main(String[] args) {
        countDown();
    }

    // 虽然能够倒计数，但是顺序不能够保证
    private static void countDown() {
        CountDownLatch countDownLatch = new CountDownLatch(6);
        for (int i = 0; i < 6; i++) {
            int finalI = i;
            new Thread(() -> {
                System.out.println(finalI + " get out");
                countDownLatch.countDown();
            }).start();
        }
        try {
            countDownLatch.await();
            System.out.println("count down finish");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
